from datetime import datetime 
from passlib.context import CryptContext 
from ..servies.user import UserServeries 


pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

class PasslibHelper: 
    
    @staticmethod 
    def verity_password(plain_password: str, hashed_password: str): 
        return pwd_context.verify(plain_password, hashed_password)
    

    @staticmethod 
    def hash_password(password: str) -> str: 
        return pwd_context.hash(password)
    

if __name__ == '__main__': 
    import asyncio 
    from ..dependencies import get_db_session_asynccont 
    
    async def create_admin_user(): 
        async with get_db_session_asynccont() as async_session: 
            await UserServeries.create_user(async_session, 
                                            username = 'admin', 
                                            password = PasslibHelper.hash_password('123456'), 
                                            created_at = datetime.now()
                                            )
    
    asyncio.run(create_admin_user())

        